package com.simplelove.common;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * 统一响应结果类
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Result<T> {
    
    private Boolean success;
    private String message;
    private T data;
    
    public Result() {}
    
    public Result(Boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }
    
    public static <T> Result<T> success() {
        return new Result<>(true, "操作成功", null);
    }
    
    public static <T> Result<T> success(T data) {
        return new Result<>(true, "操作成功", data);
    }
    
    public static <T> Result<T> success(String message, T data) {
        return new Result<>(true, message, data);
    }
    
    public static <T> Result<T> error() {
        return new Result<>(false, "操作失败", null);
    }
    
    public static <T> Result<T> error(String message) {
        return new Result<>(false, message, null);
    }
    
    public static <T> Result<T> error(String message, T data) {
        return new Result<>(false, message, data);
    }
    
    // Getters and Setters
    public Boolean getSuccess() {
        return success;
    }
    
    public void setSuccess(Boolean success) {
        this.success = success;
    }
    
    public String getMessage() {
        return message;
    }
    
    public void setMessage(String message) {
        this.message = message;
    }
    
    public T getData() {
        return data;
    }
    
    public void setData(T data) {
        this.data = data;
    }
}
